package xiaolong.zhou.spring_demo.Utils;

import java.security.SecureRandom;

public class VerCodeGenerateUtil {
    private static final String SYMBOLS = "0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZ";
    private static final SecureRandom RAND = new SecureRandom();
    /**
     * 生成 6 位数的随机数字
     * @return {@link String 验证码}
     */
    public static String generateVerCode(){
        char[] code = new char[6];
        for(int i = 0; i < code.length; i++) {
            code[i] = SYMBOLS.charAt(RAND.nextInt(SYMBOLS.length()));
        }
        return new String(code);
    }
}
